package com.example.zsfinacialmanage.adapter;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.example.zsfinacialmanage.R;
import com.example.zsfinacialmanage.bean.IncomeBran;
import com.example.zsfinacialmanage.bean.OutpayBean;
import com.example.zsfinacialmanage.other.OutManageActivity;
import java.util.List;
public class OutpayAdapter  extends RecyclerView.Adapter<OutpayAdapter.ViewHolder> {
    Context mcontext;
    List<OutpayBean> arr2;
    public OutpayAdapter(Context mcontext, List<OutpayBean>arr2) {
        this.mcontext = mcontext;
        this.arr2=arr2;
    }
    @Override
    public OutpayAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mcontext).inflate(R.layout.recy_item_out, parent, false);
        OutpayAdapter.ViewHolder mholder=new OutpayAdapter.ViewHolder(view);
        return mholder;
    }
    @Override
    public void onBindViewHolder(OutpayAdapter.ViewHolder mholder, int position) {
        final OutpayBean outpayBean=arr2.get(position);
        mholder.item_payee.setText("付款-给"+outpayBean.getPayee());
        mholder.item_type.setText(outpayBean.getType());
        mholder.item_time.setText(outpayBean.getTime());
        mholder.item_remark.setText(outpayBean.getRemark());
        mholder.item_money.setText("-"+outpayBean.getMoney());
        mholder.itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent=new Intent(mcontext, OutManageActivity.class);
                intent.putExtra("seri",outpayBean);
                mcontext.startActivity(intent);
                ((Activity)mcontext).finish();
            }
        });
    }
    @Override
    public int getItemCount() {
        return arr2.size();
    }
    public class ViewHolder extends RecyclerView.ViewHolder {
        TextView item_payee,item_type,item_time,item_remark,item_money;
        public ViewHolder(View view) {
            super(view);
            item_payee=view.findViewById(R.id.item_payee_out);
            item_type=view.findViewById(R.id.item_type_out);
            item_time=view.findViewById(R.id.item_time_out);
            item_remark=view.findViewById(R.id.item_remark_out);
            item_money=view.findViewById(R.id.item_money_out);
        }
    }
}
